package com.dlc.shop.seckill.common.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.dlc.shop.seckill.common.model.Seckill;
import com.dlc.shop.seckill.common.model.SeckillSku;

import java.util.List;
import java.util.Map;

/**
 * 秒杀活动sku
 *
 * @author LGH
 * @date 2019-08-28 09:36:59
 */
public interface SeckillSkuService extends IService<SeckillSku> {

    /**
     * 获取某个活动的秒杀sku列表
     * @param seckillId
     * @return
     */
    List<SeckillSku> listSeckillSkuBySeckillId(Long seckillId);

    /**
     * 删除秒杀活动商品的缓存
     * @param seckillId
     */
    void removeSeckillSkuCacheBySeckillId(Long seckillId);

    /**
     * 获取秒杀商品
     * @param seckillSkuId
     * @return
     */
    SeckillSku getSeckillSkuById(Long seckillSkuId);

    /**
     * 删除缓存
     * @param seckillSkuId
     * @param seckillId
     */
    void removeSeckillCacheSkuById(Long seckillSkuId,Long seckillId);

    /**
     * 更新秒杀商品sku库存
     * @param seckillSkuId 秒杀商品skuId
     * @param changeStock 库存变化量
     */
    void updateSeckillSkuStocks(Long seckillSkuId, Integer changeStock);

    /**
     * 批量保存秒杀活动sku
     * @param seckillSkuList
     */
    void saveSeckillSkuStockBatch(List<SeckillSku> seckillSkuList);

    /**
     * 根据秒杀skuId从redis获取库存
     * @param activityId
     * @param skuId
     * @param stockPointIds
     * @return
     */
    Map<Long, Integer> getPointStockBySeckillSkuId(Long activityId, Long skuId, List<Long> stockPointIds);

    /**
     * 从redis补充库存
     * @param seckill
     * @return
     */
    void handSeckillPointSku(Seckill seckill);
}
